<template>
  <el-button
    v-if="status !== 1"
    type="text"
    @click="handleExam"
  >{{getStore}}</el-button>
</template>

<script>
export default {
  props: ["status", "taskId", "id"],
  computed: {
    getStore() {
      if (
        this.status === undefined ||
        this.status === null ||
        this.status === "" ||
        this.status === 3
      ) {
        return "发起审批";
      } else if (this.status === 0) {
        return "撤销";
      } else if (this.status === 1) {
        return "";
      } else if (this.status === 2) {
        return "重新发起";
      }
    },
  },
  methods: {
    handleExam() {
      if (this.status === 0) {
        this.$confirm("是否撤销审批?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.$http.rescinded(this.taskId).then(() => {
            this.$emit("getList");
            this.$store.dispatch("GetMessages");
            this.$modal.msgSuccess("撤销成功");
          });
        });
      } else {
        this.$emit("change", this.taskId, this.id);
      }
    },
  },
};
</script>

<style>
</style>
